package operation;

import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookList booklist) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("查找图书...");
        System.out.println("请输入要查找的图书:");
        String name = scanner.nextLine();
        int i = 0;
        int currentSize = booklist.getUsedSize();
        for (i = 0; i < currentSize; i++) {
            if(booklist.findBook(i).getName().equals(name)) {
                System.out.println("成功找到，信息如下:");
                System.out.println(booklist.findBook(i));
                System.out.println("--------------------------------------");                break;
            }
        }
        if(i >= currentSize) {
            System.out.println("该图书尚未添加...");
            System.out.println("--------------------------------------");        }
    }
}
